/* -----------------
* brief
* 1. this is code gen by tools
 */

package service

import (
	"errors"

	"saas_sys_base/common"
	// "saas_sys_base/config"
	// configService "saas_sys_base/modules/config/service"
	userService "saas_sys_base/modules/user/service"
)

type WxTenantUserService struct {
	userService.WxUserService
	tenantService TenantService
}

//自定义函数
func (t *WxTenantUserService) UserLogin(whoApp common.Who, code string, EncryptedData, iv string) (user *userService.LoginUser, tokenString string, err error) {

	dbuser, tokenString, err := t.WxUserService.UserLogin(whoApp, code, EncryptedData, iv)
	if err != nil {
		return nil, "", err
	}
	hasPermission := t.tenantService.HasPermissionInTenant(&whoApp, whoApp.TenantId, dbuser.User.Id)
	if hasPermission != true {
		return nil, "", errors.New("无权限")
	}

	return dbuser, tokenString, nil
}
